using RxjhServer.DbClss;
using RxjhServer.HelperTools;
using RxjhServer.Network;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Timers;

namespace RxjhServer
{
	public class NpcClass : IDisposable
	{
		private Random Randomd = new Random();

		private object AsyncLock = new object();

		private object HitLock = new object();

		private object AsyncLocksw = new object();

		private ThreadSafeDictionary<int, Players> PlayList;

		private Dictionary<int, NpcClass> NpcList;

		private ArrayList tem = new ArrayList();

		private List<PlayGjClass> PlayGjList = new List<PlayGjClass>();

		private ThreadSafeDictionary<int, PlayZDClass> 组队列表 = new ThreadSafeDictionary<int, PlayZDClass>();

		private object thisLock1 = new object();

		private object thisLock2 = new object();

		public System.Timers.Timer 自动移动;

		public System.Timers.Timer 自动攻击;

		public System.Timers.Timer 自动复活;

		public static Random Ran = new Random();

		private Random publicRan = new Random();

		private float _FLD_FACE1;

		private float _FLD_FACE2;

		private int _IsNpc;

		private string _Name;

		private int _FLD_INDEX;

		private int _FLD_PID;

		private double _FLD_AT;

		private float _Rxjh_X;

		private float _Rxjh_Y;

		private float _Rxjh_Z;

		private float _Rxjh_cs_X;

		private float _Rxjh_cs_Y;

		private float _Rxjh_cs_Z;

		private int _Rxjh_Map;

		private int _Rxjh_Exp;

		private int _Max_Rxjh_HP;

		private int _Rxjh_HP;

		private int _Level;

		private double _FLD_DF;

		private int _FLD_AUTO;

		private int _FLD_BOSS;

		private int _FLD_NEWTIME;

		private bool _NPC死亡;

		private bool _一次性怪;

		public int PlayerWid
		{
			get
			{
				if (PlayGjList.Count <= 0)
				{
					return 0;
				}
				int result;
				try
				{
					PlayGjClass playGjClass = new PlayGjClass();
					Reverser<PlayGjClass> comparer = new Reverser<PlayGjClass>(playGjClass.GetType(), "Gjsl", ReverserInfo.Direction.DESC);
					PlayGjList.Sort(comparer);
					result = PlayGjList[0].HitPlayID;
				}
				catch (Exception)
				{
					result = 0;
				}
				return result;
			}
		}

		public int UserPlayerWid
		{
			get
			{
				if (PlayGjList.Count <= 0)
				{
					return 0;
				}
				int result;
				try
				{
					PlayGjClass playGjClass = new PlayGjClass();
					Reverser<PlayGjClass> comparer = new Reverser<PlayGjClass>(playGjClass.GetType(), "Gjsl", ReverserInfo.Direction.DESC);
					PlayGjList.Sort(comparer);
					result = PlayGjList[0].PlayID;
				}
				catch (Exception)
				{
					result = 0;
				}
				return result;
			}
		}

		public int BossPlayerWid
		{
			get
			{
				if (PlayGjList.Count <= 0)
				{
					return 0;
				}
				int result;
				try
				{
					int num = 0;
					int index;
					while (true)
					{
						Random random = new Random();
						index = random.Next(0, PlayGjList.Count);
						int num2 = Max_Rxjh_HP / PlayGjList.Count;
						if (PlayGjList[index].Hitsl >= num2)
						{
							break;
						}
						if (num > PlayGjList.Count)
						{
							PlayGjClass playGjClass = new PlayGjClass();
							Reverser<PlayGjClass> comparer = new Reverser<PlayGjClass>(playGjClass.GetType(), "Gjsl", ReverserInfo.Direction.DESC);
							PlayGjList.Sort(comparer);
							return PlayGjList[0].PlayID;
						}
						num++;
					}
					result = PlayGjList[index].PlayID;
				}
				catch (Exception)
				{
					result = 0;
				}
				return result;
			}
		}

		public float FLD_FACE1
		{
			get
			{
				return _FLD_FACE1;
			}
			set
			{
				_FLD_FACE1 = value;
			}
		}

		public float FLD_FACE2
		{
			get
			{
				return _FLD_FACE2;
			}
			set
			{
				_FLD_FACE2 = value;
			}
		}

		public int IsNpc
		{
			get
			{
				return _IsNpc;
			}
			set
			{
				_IsNpc = value;
			}
		}

		public string Name
		{
			get
			{
				return _Name;
			}
			set
			{
				_Name = value;
			}
		}

		public int FLD_INDEX
		{
			get
			{
				return _FLD_INDEX;
			}
			set
			{
				_FLD_INDEX = value;
			}
		}

		public int FLD_PID
		{
			get
			{
				return _FLD_PID;
			}
			set
			{
				_FLD_PID = value;
			}
		}

		public double FLD_AT
		{
			get
			{
				return _FLD_AT;
			}
			set
			{
				_FLD_AT = value;
			}
		}

		public float Rxjh_X
		{
			get
			{
				return _Rxjh_X;
			}
			set
			{
				_Rxjh_X = value;
			}
		}

		public float Rxjh_Y
		{
			get
			{
				return _Rxjh_Y;
			}
			set
			{
				_Rxjh_Y = value;
			}
		}

		public float Rxjh_Z
		{
			get
			{
				return _Rxjh_Z;
			}
			set
			{
				_Rxjh_Z = value;
			}
		}

		public float Rxjh_cs_X
		{
			get
			{
				return _Rxjh_cs_X;
			}
			set
			{
				_Rxjh_cs_X = value;
			}
		}

		public float Rxjh_cs_Y
		{
			get
			{
				return _Rxjh_cs_Y;
			}
			set
			{
				_Rxjh_cs_Y = value;
			}
		}

		public float Rxjh_cs_Z
		{
			get
			{
				return _Rxjh_cs_Z;
			}
			set
			{
				_Rxjh_cs_Z = value;
			}
		}

		public int Rxjh_Map
		{
			get
			{
				return _Rxjh_Map;
			}
			set
			{
				_Rxjh_Map = value;
			}
		}

		public int Rxjh_Exp
		{
			get
			{
				return _Rxjh_Exp;
			}
			set
			{
				_Rxjh_Exp = value;
			}
		}

		public int Max_Rxjh_HP
		{
			get
			{
				return _Max_Rxjh_HP;
			}
			set
			{
				_Max_Rxjh_HP = value;
			}
		}

		public int Rxjh_HP
		{
			get
			{
				return _Rxjh_HP;
			}
			set
			{
				_Rxjh_HP = value;
			}
		}

		public int Level
		{
			get
			{
				return _Level;
			}
			set
			{
				_Level = value;
			}
		}

		public double FLD_DF
		{
			get
			{
				return _FLD_DF;
			}
			set
			{
				_FLD_DF = value;
			}
		}

		public int FLD_AUTO
		{
			get
			{
				return _FLD_AUTO;
			}
			set
			{
				_FLD_AUTO = value;
			}
		}

		public int FLD_BOSS
		{
			get
			{
				return _FLD_BOSS;
			}
			set
			{
				_FLD_BOSS = value;
			}
		}

		public int FLD_NEWTIME
		{
			get
			{
				return _FLD_NEWTIME;
			}
			set
			{
				_FLD_NEWTIME = value;
			}
		}

		public bool NPC死亡
		{
			get
			{
				return _NPC死亡;
			}
			set
			{
				_NPC死亡 = value;
			}
		}

		public bool 一次性怪
		{
			get
			{
				return _一次性怪;
			}
			set
			{
				_一次性怪 = value;
			}
		}

		public void PlayList_Add(Players payer)
		{
			PlayList.Add(payer.人物全服ID, payer);
		}

		public void PlayList_Remove(Players payer)
		{
			PlayList.Remove(payer.人物全服ID);
		}

		public bool Contains(Players payer)
		{
			return PlayList.ContainsKey(payer.人物全服ID);
		}

		public void Play_Add(Players payer)
		{
			foreach (PlayGjClass playGj in PlayGjList)
			{
				if (playGj.PlayID == payer.人物全服ID)
				{
					playGj.Gjsl++;
					return;
				}
			}
			PlayGjClass playGjClass = new PlayGjClass();
			playGjClass.Hitsl = 0;
			playGjClass.Gjsl = 1;
			playGjClass.PlayID = payer.人物全服ID;
			playGjClass.HitPlayID = payer.人物全服ID;
			PlayGjList.Add(playGjClass);
		}

		public void Play_Hit(Players payer, int 攻击数量)
		{
			using (new Lock(HitLock, "Play_Hit"))
			{
				if (Rxjh_HP < 0)
				{
					攻击数量 += Rxjh_HP;
				}
				if (攻击数量 >= 0)
				{
					foreach (PlayGjClass playGj in PlayGjList)
					{
						if (playGj.PlayID == payer.人物全服ID)
						{
							playGj.Hitsl += 攻击数量;
							break;
						}
						if (payer.人物灵兽 != null && playGj.HitPlayID == payer.人物灵兽.全服ID)
						{
							playGj.Hitsl += 攻击数量;
							break;
						}
					}
					if (payer.组队id != 0 && !组队列表.ContainsKey(payer.组队id))
					{
						PlayZDClass playZDClass = new PlayZDClass();
						playZDClass.dwID = payer.组队id;
						playZDClass.Hitsl = 0;
						组队列表.Add(playZDClass.dwID, playZDClass);
					}
				}
			}
		}

		public void Play_Add(Players payer, 灵兽类 pat)
		{
			foreach (PlayGjClass playGj in PlayGjList)
			{
				if (playGj.HitPlayID == pat.全服ID)
				{
					playGj.Gjsl++;
					return;
				}
			}
			PlayGjClass playGjClass = new PlayGjClass();
			playGjClass.Hitsl = 0;
			playGjClass.Gjsl = 1;
			playGjClass.PlayID = payer.人物全服ID;
			playGjClass.HitPlayID = pat.全服ID;
			PlayGjList.Add(playGjClass);
		}

		public void Play_null()
		{
			try
			{
				if (PlayGjList.Count > 0)
				{
					PlayGjList.Clear();
				}
				if (组队列表.Count > 0)
				{
					组队列表.Clear();
				}
			}
			catch
			{
			}
		}

		public NpcClass()
		{
			PlayList = new ThreadSafeDictionary<int, Players>();
			NpcList = new Dictionary<int, NpcClass>();
			double interval = Ran.Next(3000, 15000);
			自动移动 = new System.Timers.Timer(interval);
			自动移动.Elapsed += 自动移动事件;
			自动移动.AutoReset = true;
			自动移动.Enabled = true;
			自动攻击 = new System.Timers.Timer(1000.0);
			自动攻击.Elapsed += 自动攻击事件;
			自动攻击.AutoReset = true;
		}

		public void 获取范围玩家发送增加数据包()
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(1, "NpcClass_获取范围玩家发送增加数据包");
			}
			try
			{
				foreach (Players value in World.allConnectedChars.Values)
				{
					if (查找范围玩家(400, value))
					{
						value.获取复查范围Npc();
					}
				}
			}
			catch (Exception ex)
			{
				Form1.WriteLine(1, "获取范围玩家发送地面增加Npc数据包 出错：" + ex?.ToString());
			}
		}

		public void 获取范围玩家发送增加数据包A()
		{
			try
			{
				foreach (Players value in World.allConnectedChars.Values)
				{
					if (查找范围玩家(400, value))
					{
						value.获取复查范围NpcA();
					}
				}
			}
			catch (Exception ex)
			{
				Form1.WriteLine(1, "获取范围玩家发送地面增加Npc数据包   出错：" + ex?.ToString());
			}
		}

		public void Dispose()
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(1, "NpcClass_Dispose");
			}
			try
			{
				MapClass.delnpc(Rxjh_Map, FLD_INDEX);
				if (自动攻击 != null)
				{
					自动攻击.Enabled = false;
					自动攻击.Close();
					自动攻击.Dispose();
				}
				if (自动移动 != null)
				{
					自动移动.Enabled = false;
					自动移动.Close();
					自动移动.Dispose();
				}
				if (自动复活 != null)
				{
					自动复活.Enabled = false;
					自动复活.Close();
					自动复活.Dispose();
					自动复活 = null;
				}
				Play_null();
				获取范围玩家发送消失数据包();
				NpcList.Clear();
				tem.Clear();
				if (PlayList != null)
				{
					PlayList.Dispose();
					PlayList = null;
				}
				if (NpcList != null)
				{
					NpcList = null;
				}
			}
			catch (Exception ex)
			{
				Form1.WriteLine(1, "NPC 关闭数据Dispose() 出错：" + ex?.ToString());
			}
		}

		public void 获取范围玩家发送消失数据包()
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(1, "NpcClass_获取范围玩家发送消失数据包");
			}
			try
			{
				foreach (Players value in PlayList.Values)
				{
					value.获取复查范围Npc();
				}
			}
			catch (Exception ex)
			{
				Form1.WriteLine(1, "NPC 获取范围玩家发送消失数据包3 出错：" + ex?.ToString());
			}
		}

		public void getbl()
		{
			if (PlayList.Count > 0)
			{
				Form1.WriteLine(3, _Name + " 人物：" + PlayList.Count.ToString());
				if (自动移动 != null)
				{
					Form1.WriteLine(3, _Name + " 人物_自动移动：" + 自动移动.Enabled.ToString());
				}
				if (自动攻击 != null)
				{
					Form1.WriteLine(3, _Name + " 人物_自动攻击：" + 自动攻击.Enabled.ToString());
				}
				if (自动复活 != null)
				{
					Form1.WriteLine(3, _Name + " 人物_自动复活：" + 自动复活.Enabled.ToString());
				}
			}
			if (NpcList.Count > 0)
			{
				Form1.WriteLine(3, _Name + " NPC：" + NpcList.Count.ToString());
			}
			if (PlayGjList.Count > 0)
			{
				Form1.WriteLine(3, _Name + " 攻击：" + PlayGjList.Count.ToString());
			}
		}

		public void 获得分配经验()
		{
			if (Rxjh_Exp > 0)
			{
				double num = World.经验倍数;
				if (World.是否开启高倍经验 == 1)
				{
					num *= World.高倍经验倍数;
				}
				double num2 = (double)Rxjh_Exp * num * (1.0 - World.经验获得降低百分比);
				int num3 = (int)(num2 / 10.0);
				double num4 = num2;
				int num5 = (int)((double)Rxjh_Exp * World.钱倍数 / 20.0);
				int num6 = num5 / 3;
				double num7 = publicRan.Next(num5 - num6, num5 + num6);
				double num8 = (double)Rxjh_Exp * World.历练倍数 / (double)Level / 2.0 * (1.0 - World.历练获得降低百分比);
				int maxValue = (int)(num8 / 3.0);
				double num9 = num8 + (double)publicRan.Next(0, maxValue);
				if (Rxjh_Map == 1301 || Rxjh_Map == 2001)
				{
					num4 *= World.南明湖经验倍数;
				}
				else if (Rxjh_Map == 5001)
				{
					num4 *= World.北海经验倍数;
				}
				foreach (PlayGjClass playGj in PlayGjList)
				{
					if (World.allConnectedChars.TryGetValue(playGj.PlayID, out Players value))
					{
						if (value.组队id != 0)
						{
							if (World.W组队.TryGetValue(value.组队id, out 组队Class value2))
							{
								if (value2.组队列表.ContainsKey(value.人物全服ID))
								{
									foreach (PlayZDClass value4 in 组队列表.Values)
									{
										if (value.组队id == value4.dwID)
										{
											if (查找范围玩家(World.组队获得经验范围, value))
											{
												value4.Hitsl += playGj.Hitsl;
											}
											break;
										}
									}
								}
								else if (查找范围玩家(World.组队获得经验范围, value))
								{
									double num10 = num4 * (double)playGj.Hitsl / (double)Max_Rxjh_HP;
									double num11 = 1.0 + num9 * (double)playGj.Hitsl / (double)Max_Rxjh_HP;
									double num12 = 1.0 + num7 * (double)playGj.Hitsl / (double)Max_Rxjh_HP;
									if (value.检查公有药品())
									{
										num10 += num10 * 0.2;
										num11 += num11 * 0.5;
										num12 += num12 * 0.2;
									}
									if (value.Player_Level < World.自定义等级一阶段)
									{
										num10 *= World.第一阶段经验倍数;
										num12 *= 2.0;
									}
									else if (value.Player_Level < World.自定义等级二阶段)
									{
										num10 *= World.第二阶段经验倍数;
										num12 *= 1.0;
									}
									else if (value.Player_Level < World.自定义等级三阶段)
									{
										num10 *= World.第三阶段经验倍数;
										num12 /= 1.5;
									}
									else if (value.Player_Level < World.自定义等级四阶段)
									{
										num10 *= World.第四阶段经验倍数;
										num12 /= 1.5;
									}
									else if (value.Player_Level < World.自定义等级五阶段)
									{
										num10 *= World.第五阶段经验倍数;
										num12 /= 2.0;
									}
									else if (value.Player_Level < World.自定义等级六阶段)
									{
										num10 *= World.第六阶段经验倍数;
										num12 /= 2.2;
									}
									else
									{
										num12 /= 2.0;
									}
									if (value.Player_Level < 60 && (Level - value.Player_Level >= World.获得经验等级差上线 || value.Player_Level - Level >= World.获得经验等级差下线 || DateTime.Now.Subtract(value.上次死亡时间).TotalSeconds < 30.0))
									{
										value.系统提示("您的等级已超越怪物" + World.获得经验等级差上线.ToString() + "级,或您的等级已高于怪物" + World.获得经验等级差上线.ToString() + "级", 10, "无经验提示");
										num10 *= 0.0;
										num12 *= 0.0;
									}
									if (DateTime.Now.Subtract(value.上次死亡时间).TotalSeconds < 30.0)
									{
										value.系统提示("死亡30内无经验", 10, "无经验提示");
										num10 *= 0.0;
										num12 *= 0.0;
									}
									if (value.Player_Level >= World.人物最高等级 || value.Player_Level >= World.封印等级)
									{
										num10 *= 0.0;
										num12 *= 1.0;
									}
									else if (value.Player_Level >= 60)
									{
										num10 /= 2.0;
										num12 /= 2.0;
									}
									value.人物获得经验(num10 * (1.0 + value.人物_追加_经验百分比));
									value.人物获得金币((int)(num12 * (1.0 + value.人物_追加_金钱百分比)), 1);
									value.Player_ExpErience += (int)(num11 * (1.0 + value.FLD_人物_追加_历练百分比));
									value.得到钱的提示((uint)(num12 * (1.0 + value.人物_追加_金钱百分比)));
									value.计算人物基本数据3();
									value.更新经验和历练();
									value.更新金钱和负重();
								}
							}
							else if (查找范围玩家(World.组队获得经验范围, value) && value.Player_LockState != 0)
							{
								double num13 = num4 * (double)playGj.Hitsl / (double)Max_Rxjh_HP;
								double num14 = 1.0 + num9 * (double)playGj.Hitsl / (double)Max_Rxjh_HP;
								double num15 = 1.0 + num7 * (double)playGj.Hitsl / (double)Max_Rxjh_HP;
								if (value.检查公有药品())
								{
									num13 += num13 * 0.2;
									num14 += num14 * 0.5;
									num15 += num15 * 0.2;
								}
								if (value.Player_Level < World.自定义等级一阶段)
								{
									num13 *= World.第一阶段经验倍数;
									num15 *= 2.0;
								}
								else if (value.Player_Level < World.自定义等级二阶段)
								{
									num13 *= World.第二阶段经验倍数;
									num15 *= 1.0;
								}
								else if (value.Player_Level < World.自定义等级三阶段)
								{
									num13 *= World.第三阶段经验倍数;
									num15 /= 1.5;
								}
								else if (value.Player_Level < World.自定义等级四阶段)
								{
									num13 *= World.第四阶段经验倍数;
									num15 /= 1.5;
								}
								else if (value.Player_Level < World.自定义等级五阶段)
								{
									num13 *= World.第五阶段经验倍数;
									num15 /= 2.0;
								}
								else if (value.Player_Level < World.自定义等级六阶段)
								{
									num13 *= World.第六阶段经验倍数;
									num15 /= 2.0;
								}
								if (value.Player_Level < 60 && (Level - value.Player_Level >= World.获得经验等级差上线 || value.Player_Level - Level >= World.获得经验等级差下线 || DateTime.Now.Subtract(value.上次死亡时间).TotalSeconds < 30.0))
								{
									num13 *= 0.0;
									num15 *= 0.0;
								}
								if (DateTime.Now.Subtract(value.上次死亡时间).TotalSeconds < 30.0)
								{
									value.系统提示("死亡30内无经验", 10, "无经验提示");
									num13 *= 0.0;
									num15 *= 0.0;
								}
								if (value.Player_Level >= World.人物最高等级 || value.Player_Level >= World.封印等级)
								{
									num13 *= 0.0;
									num15 *= 1.0;
								}
								else if (value.Player_Level >= 60)
								{
									num13 /= 2.0;
									num15 /= 2.0;
								}
								value.人物获得经验(num13 * (1.0 + value.人物_追加_经验百分比));
								value.人物获得金币((int)(num15 * (1.0 + value.人物_追加_金钱百分比)), 1);
								value.Player_ExpErience += (int)(num14 * (1.0 + value.FLD_人物_追加_历练百分比));
								value.得到钱的提示((uint)(num15 * (1.0 + value.人物_追加_金钱百分比)));
								value.计算人物基本数据3();
								value.更新经验和历练();
								value.更新金钱和负重();
							}
						}
						else if (查找范围玩家(World.组队获得经验范围, value) && value.Player_LockState != 0)
						{
							double num16 = num4 * (double)playGj.Hitsl / (double)Max_Rxjh_HP;
							double num17 = 1.0 + num9 * (double)playGj.Hitsl / (double)Max_Rxjh_HP;
							double num18 = 1.0 + num7 * (double)playGj.Hitsl / (double)Max_Rxjh_HP;
							if (value.检查公有药品())
							{
								num16 += num16 * 0.2;
								num17 += num17 * 0.5;
								num18 += num18 * 0.2;
							}
							if (value.Player_Level < World.自定义等级一阶段)
							{
								num16 *= World.第一阶段经验倍数;
								num18 *= 2.0;
							}
							else if (value.Player_Level < World.自定义等级二阶段)
							{
								num16 *= World.第二阶段经验倍数;
								num18 *= 1.0;
							}
							else if (value.Player_Level < World.自定义等级三阶段)
							{
								num16 *= World.第三阶段经验倍数;
								num18 /= 1.5;
							}
							else if (value.Player_Level < World.自定义等级四阶段)
							{
								num16 *= World.第四阶段经验倍数;
								num18 /= 1.5;
							}
							else if (value.Player_Level < World.自定义等级五阶段)
							{
								num16 *= World.第五阶段经验倍数;
								num18 /= 2.0;
							}
							else if (value.Player_Level < World.自定义等级六阶段)
							{
								num16 *= World.第六阶段经验倍数;
								num18 /= 2.2;
							}
							else
							{
								num18 /= 2.0;
							}
							if (value.Player_Level < 60 && (Level - value.Player_Level >= World.获得经验等级差上线 || value.Player_Level - Level >= World.获得经验等级差下线 || DateTime.Now.Subtract(value.上次死亡时间).TotalSeconds < 30.0))
							{
								num16 *= 0.0;
								num18 *= 0.0;
							}
							if (DateTime.Now.Subtract(value.上次死亡时间).TotalSeconds < 30.0)
							{
								value.系统提示("死亡30内无经验", 10, "无经验提示");
								num16 *= 0.0;
								num18 *= 0.0;
							}
							if (value.Player_Level >= World.人物最高等级 || value.Player_Level >= World.封印等级)
							{
								num16 *= 0.0;
								num18 *= 1.0;
							}
							else if (value.Player_Level >= 60)
							{
								num16 /= 2.0;
								num18 /= 2.0;
							}
							value.人物获得经验(num16 * (1.0 + value.人物_追加_经验百分比));
							value.人物获得金币((int)(num18 * (1.0 + value.人物_追加_金钱百分比)), 1);
							value.Player_ExpErience += (int)(num17 * (1.0 + value.FLD_人物_追加_历练百分比));
							value.得到钱的提示((uint)(num18 * (1.0 + value.人物_追加_金钱百分比)));
							value.计算人物基本数据3();
							value.更新经验和历练();
							value.更新金钱和负重();
						}
					}
				}
				foreach (PlayZDClass value5 in 组队列表.Values)
				{
					if (World.W组队.TryGetValue(value5.dwID, out 组队Class value3))
					{
						bool flag = false;
						bool flag2 = false;
						bool flag3 = false;
						bool flag4 = false;
						int num19 = 0;
						int num20 = 0;
						int num21 = 0;
						int num22 = 0;
						int num23 = 0;
						int num24 = 0;
						foreach (Players value6 in value3.组队列表.Values)
						{
							if (查找范围玩家(World.组队获得经验范围, value6) && value6.人物_HP > 0 && !value6.Player死亡)
							{
								num24++;
							}
						}
						if (num24 == 0)
						{
							num24 = 1;
						}
						foreach (Players value7 in value3.组队列表.Values)
						{
							if (查找范围玩家(World.组队获得经验范围, value7) && value7.Player_Job != 1)
							{
								if (value7.Player_Job == 2)
								{
									flag = true;
								}
								else if (value7.Player_Job == 3)
								{
									flag2 = true;
								}
								else if (value7.Player_Job == 4)
								{
									flag3 = true;
								}
								else if (value7.Player_Job == 5)
								{
									flag4 = true;
								}
							}
							if (value7.Player_Job == 1)
							{
								num19++;
							}
							else if (value7.Player_Job == 2)
							{
								num20++;
							}
							else if (value7.Player_Job == 3)
							{
								num21++;
							}
							else if (value7.Player_Job == 4)
							{
								num22++;
							}
							else if (value7.Player_Job == 5)
							{
								num23++;
							}
						}
						string[] array = World.组队经验加成.Split(';');
						foreach (Players value8 in value3.组队列表.Values)
						{
							if (查找范围玩家(World.组队获得经验范围, value8) && value5.dwID == value8.组队id && value8.Player_Level - Level < World.获得经验等级差下线 && !value8.Player死亡 && value8.Player_LockState != 0)
							{
								double num25 = num4 * (double)value5.Hitsl / (double)Max_Rxjh_HP * (1.0 + (double)num24 * 0.1) / (double)num24;
								double num26 = 1.0 + num9 * (double)value5.Hitsl / (double)Max_Rxjh_HP * (1.0 + (double)num24 * 0.1) / (double)num24;
								double num27 = 1.0 + num7 * (double)value5.Hitsl / (double)Max_Rxjh_HP * (1.0 + (double)num24 * 0.1) / (double)num24;
								switch (num24)
								{
								case 1:
									num25 = num4 * (double)value5.Hitsl / (double)Max_Rxjh_HP;
									num26 = num9 * (double)value5.Hitsl / (double)Max_Rxjh_HP;
									num27 = num7 * (double)value5.Hitsl / (double)Max_Rxjh_HP;
									break;
								case 8:
									num25 += num25 * double.Parse(array[6]);
									break;
								case 7:
									num25 += num25 * double.Parse(array[5]);
									break;
								case 6:
									num25 += num25 * double.Parse(array[4]);
									break;
								case 5:
									num25 += num25 * double.Parse(array[3]);
									break;
								case 4:
									num25 += num25 * double.Parse(array[2]);
									break;
								case 3:
									num25 += num25 * double.Parse(array[1]);
									break;
								case 2:
									num25 += num25 * double.Parse(array[0]);
									break;
								}
								if (num19 > World.刀客数量)
								{
									num25 -= num25 * World.刀客经验减少;
									value8.系统提示("当前队伍刀客数量大于[" + World.刀客数量.ToString() + "],经验减少[百分之" + (World.刀客经验减少 * 100.0).ToString() + "]", 20, "刀数量提示");
								}
								if (num20 > World.剑客数量)
								{
									num25 -= num25 * World.剑客经验减少;
									value8.系统提示("当前队伍剑客数量大于[" + World.剑客数量.ToString() + "],经验减少[百分之" + (World.剑客经验减少 * 100.0).ToString() + "]", 20, "剑数量提示");
								}
								if (num21 > World.枪客数量)
								{
									num25 -= num25 * World.枪客经验减少;
									value8.系统提示("当前队伍枪客数量大于[" + World.枪客数量.ToString() + "],经验减少[百分之" + (World.枪客经验减少 * 100.0).ToString() + "]", 20, "枪数量提示");
								}
								if (num22 > World.弓箭手数量)
								{
									num25 -= num25 * World.弓箭手经验减少;
									value8.系统提示("当前队伍弓数量大于[" + World.弓箭手数量.ToString() + "],经验减少[百分之" + (World.弓箭手经验减少 * 100.0).ToString() + "]", 20, "弓数量提示");
								}
								if (num23 > World.医生数量)
								{
									num25 -= num25 * World.医生经验减少;
									value8.系统提示("当前队伍医生数量大于[" + World.医生数量.ToString() + "],经验减少[百分之" + (World.医生经验减少 * 100.0).ToString() + "]", 20, "医数量提示");
								}
								if (value8.检查公有药品())
								{
									num25 += num25 * 0.2;
									num26 += num26 * 0.5;
									num27 += num27 * 0.2;
								}
								if (value8.Player_Level < World.自定义等级一阶段)
								{
									num25 *= World.第一阶段经验倍数;
									num27 *= 2.0;
								}
								else if (value8.Player_Level < World.自定义等级二阶段)
								{
									num25 *= World.第二阶段经验倍数;
									num27 *= 1.0;
								}
								else if (value8.Player_Level < World.自定义等级三阶段)
								{
									num25 *= World.第三阶段经验倍数;
									num27 /= 1.5;
								}
								else if (value8.Player_Level < World.自定义等级四阶段)
								{
									num25 *= World.第四阶段经验倍数;
									num27 /= 1.5;
								}
								else if (value8.Player_Level < World.自定义等级五阶段)
								{
									num25 *= World.第五阶段经验倍数;
									num27 /= 2.0;
								}
								else if (value8.Player_Level < World.自定义等级六阶段)
								{
									num25 *= World.第六阶段经验倍数;
									num27 /= 2.2;
								}
								else
								{
									num27 /= 2.0;
								}
								if (World.满职业经验增加是否开启 == 1)
								{
									num25 += num25 * World.满职业经验增加;
								}
								else if ((World.满职业经验增加是否开启 == 1 && flag) & flag2 & flag4)
								{
									num25 += num25 * World.满职业经验增加;
								}
								else if ((World.满职业经验增加是否开启 == 1 && flag) & flag3 & flag4)
								{
									num25 += num25 * World.满职业经验增加;
								}
								else if ((World.满职业经验增加是否开启 == 1 && flag2) & flag3 & flag4)
								{
									num25 += num25 * World.满职业经验增加;
								}
								if (value8.Player_Level < 60 && (Level - value8.Player_Level >= World.获得经验等级差上线 || value8.Player_Level - Level >= World.获得经验等级差下线 || DateTime.Now.Subtract(value8.上次死亡时间).TotalSeconds < 30.0))
								{
									num25 *= 0.0;
									num27 *= 0.0;
								}
								if (DateTime.Now.Subtract(value8.上次死亡时间).TotalSeconds < 30.0)
								{
									value8.系统提示("死亡30内无经验", 10, "无经验提示");
									num25 *= 0.0;
									num27 *= 0.0;
								}
								if (value8.Player_Level >= World.人物最高等级 || value8.Player_Level >= World.封印等级)
								{
									num25 *= 0.0;
									num27 *= 1.0;
								}
								else if (value8.Player_Level >= 60)
								{
									num25 /= 2.0;
									num27 /= 2.0;
								}
								value8.人物获得经验(num25 * (1.0 + value8.人物_追加_经验百分比));
								value8.人物获得金币((int)(num27 * (1.0 + value8.人物_追加_金钱百分比)), 1);
								value8.Player_ExpErience += (int)(num26 * (1.0 + value8.FLD_人物_追加_历练百分比));
								value8.得到钱的提示((uint)(num27 * (1.0 + value8.人物_追加_金钱百分比)));
								value8.计算人物基本数据3();
								value8.更新经验和历练();
								value8.更新金钱和负重();
							}
						}
					}
				}
			}
		}

		private void 自动移动事件(object source, ElapsedEventArgs e)
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(1, "自动移动事件");
			}
			try
			{
				if (IsNpc != 0)
				{
					自动移动.Enabled = false;
				}
				else
				{
					if (NpcList.Count > 0)
					{
						NpcList.Clear();
					}
					if (PlayList.Count >= 1 && !NPC死亡)
					{
						if (IsNpc != 1 && FLD_AT > 0.0)
						{
							Random random = new Random();
							int num = random.Next(3000, 5000);
							自动移动.Interval = num;
							if (FLD_AUTO == 1 && 获取范围玩家())
							{
								自动移动.Enabled = false;
								自动攻击.Enabled = true;
							}
							else
							{
								发送移动数据(Rxjh_cs_X, Rxjh_cs_Y, 30, 1);
							}
						}
						else
						{
							自动移动.Interval = 20000.0;
							foreach (Players value in PlayList.Values)
							{
								if (value.Client != null)
								{
									if (!World.allConnectedChars.ContainsKey(value.Client.WorldId))
									{
										tem.Add(value);
									}
								}
								else
								{
									tem.Add(value);
								}
							}
							foreach (Players item in tem)
							{
								Form1.WriteLine(3, "NPC广播数据 删除卡号人物：[" + item.Userid + "] [" + item.UserName + "]" + FLD_INDEX.ToString());
								if (item.Client != null)
								{
									logo.KickTxtLog("NPC广播数据 删除卡号人物：[" + item.Userid + "] [" + item.UserName + "]" + FLD_INDEX.ToString());
									item.OpClient(1);
									item.Client.Dispose();
								}
								PlayList.Remove(item.人物全服ID);
							}
							tem.Clear();
						}
					}
				}
			}
			catch (Exception ex)
			{
				Form1.WriteLine(1, "自动移动事件 出错：" + ex?.ToString());
			}
		}

		private void 自动复活事件(object source, ElapsedEventArgs e)
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(1, "自动复活事件");
			}
			try
			{
				if (IsNpc == 1)
				{
					自动复活.Enabled = false;
				}
				else
				{
					自动移动.Enabled = true;
					if (NPC死亡)
					{
						更新NPC复活数据();
					}
				}
			}
			catch (Exception ex)
			{
				if (自动复活 != null)
				{
					自动复活.Enabled = false;
					自动复活.Close();
					自动复活.Dispose();
					自动复活 = null;
				}
				Form1.WriteLine(1, "自动复活事件1 出错：" + ex?.ToString());
			}
			finally
			{
				if (自动复活 != null)
				{
					自动复活.Enabled = false;
					自动复活.Close();
					自动复活.Dispose();
					自动复活 = null;
				}
			}
		}

		private void 自动攻击事件(object source, ElapsedEventArgs e)
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(1, "自动攻击事件");
			}
			try
			{
				if (IsNpc != 0)
				{
					自动攻击.Enabled = false;
				}
				else if (Rxjh_HP < 0)
				{
					自动攻击.Enabled = false;
				}
				else if (FLD_AT > 0.0)
				{
					int num = 1;
					int num2 = (int)(FLD_AT * World.怪物攻击下降倍数);
					num = 2;
					Random random = new Random();
					num = 3;
					int num3 = random.Next(1000, 2500);
					num = 4;
					if (自动攻击 != null)
					{
						自动攻击.Interval = num3;
					}
					num = 5;
					num2 = random.Next(num2 - 8, num2 + 8);
					num = 6;
					if (World.allConnectedChars.TryGetValue(PlayerWid, out Players value))
					{
						num = 7;
						if (value.自动回血开关 == 1)
						{
							num = 8;
							if (value.人物_HP <= (int)((double)value.人物最大_HP * 0.8))
							{
								value.加血(20000);
								value.吃药效果(1000000102);
								num = 9;
							}
							if (value.人物_MP <= (int)((double)value.人物最大_MP * 0.8))
							{
								num = 10;
								value.加魔(20000);
								value.吃药效果(1000000104);
							}
						}
						int 攻击类型 = 28;
						num = 11;
						if (random.Next(0, 10) < 3)
						{
							num = 12;
							攻击类型 = 29;
							num2 = (int)((double)num2 * World.怪物暴击伤害百分比);
						}
						num = 13;
						double num4 = value.FLD_人物基本_防御;
						num = 14;
						bool flag = false;
						num = 15;
						if (value.Player_Job == 3)
						{
							num = 16;
							double num5 = random.NextDouble();
							num = 17;
							if (num5 <= value.枪_转攻为守)
							{
								num = 18;
								num4 += (double)value.FLD_攻击;
							}
						}
						num = 19;
						if (value.装备栏已穿装备[0].物品属性阶段类型 == 1)
						{
							num = 20;
							num2 = (int)((double)num2 * (1.0 - (double)value.装备栏已穿装备[0].物品属性阶段数 / 100.0));
						}
						num2 = (((double)num2 <= num4) ? 1 : (num2 - (int)num4));
						num = 21;
						if (查找范围玩家(23, value))
						{
							num = 22;
							double num6 = (double)value.FLD_装备_追加_回避 / 800.0;
							num = 23;
							double num7 = random.NextDouble();
							num = 24;
							if (value.Player_Job == 2)
							{
								double num8 = num2;
								double num9 = random.NextDouble();
								double num10 = random.NextDouble();
								if (num9 < value.剑_护身罡气)
								{
									num2 = (int)(num8 * 0.5);
								}
								else if (num10 < value.剑_百变神行)
								{
									num2 = 1;
								}
								if (num7 < num6)
								{
									num2 = 1;
								}
							}
							else if (num7 < num6)
							{
								num2 = 1;
							}
							发送攻击数据(num2, 攻击类型, value.人物全服ID);
							if (value.人物_HP > 0 && !value._Player死亡)
							{
								value.人物_HP -= num2;
								try
								{
									if (!value.追加状态列表.ContainsKey(700014))
									{
										if (value.Player_Job == 3)
										{
											if (num2 <= 0)
											{
												value.人物_SP += 5;
											}
											else
											{
												value.人物_SP += (int)((double)(value.FLD_装备_追加_怒气 + 8) + (double)value.人物最大_SP * value.枪_狂神降世);
											}
										}
										else if (value.Player_Job != 5)
										{
											if (num2 <= 0)
											{
												value.人物_SP += 4;
											}
											else
											{
												value.人物_SP += 6 + value.FLD_装备_追加_怒气;
											}
										}
									}
									num = 25;
									if (value.Player_Job == 1)
									{
										Random random2 = new Random();
										int num11 = random2.Next(0, 101);
										if ((double)num11 <= value.反伤几率 * 100.0)
										{
											发送反伤攻击数据(num2, value.人物全服ID);
											Rxjh_HP -= num2;
											Play_Hit(value, num2);
											if (Rxjh_HP <= 0)
											{
												flag = true;
											}
										}
									}
								}
								catch (Exception ex)
								{
									Form1.WriteLine(1, "自动攻击事件 刀反伤 出错：" + ex?.ToString() + num.ToString());
								}
								if (value.人物_HP <= 0)
								{
									自动攻击.Enabled = false;
									自动移动.Enabled = true;
									Rxjh_X = Rxjh_cs_X;
									Rxjh_Y = Rxjh_cs_Y;
									Rxjh_Z = Rxjh_cs_Z;
									发送移动数据(Rxjh_cs_X, Rxjh_cs_Y, 35, 1);
									value.人物_HP = 0;
									value.死亡();
									value.更新HP_MP_SP();
									value.更新人物减经验();
									if (PlayGjList != null)
									{
										foreach (PlayGjClass playGj in PlayGjList)
										{
											if (playGj.PlayID == value.人物全服ID)
											{
												PlayGjList.Remove(playGj);
												break;
											}
										}
									}
								}
								else
								{
									value.更新HP_MP_SP();
								}
								if (flag)
								{
									发送死亡数据(value.人物全服ID);
								}
							}
						}
						else if (查找原始范围())
						{
							自动攻击.Enabled = false;
							自动移动.Enabled = true;
							Rxjh_X = Rxjh_cs_X;
							Rxjh_Y = Rxjh_cs_Y;
							Rxjh_Z = Rxjh_cs_Z;
							发送移动数据(Rxjh_cs_X, Rxjh_cs_Y, 35, 1);
						}
						else if (查找范围玩家(100, value))
						{
							发送移动数据(value.人物坐标_X, value.人物坐标_Y, 10, 2);
						}
						else
						{
							自动攻击.Enabled = false;
							自动移动.Enabled = true;
							Rxjh_X = Rxjh_cs_X;
							Rxjh_Y = Rxjh_cs_Y;
							Rxjh_Z = Rxjh_cs_Z;
							发送移动数据(Rxjh_cs_X, Rxjh_cs_Y, 35, 1);
						}
					}
					else
					{
						int key = (PlayerWid - 40000) / 2;
						if (World.allConnectedChars.TryGetValue(key, out value))
						{
							if (value.人物灵兽 == null)
							{
								自动攻击.Enabled = false;
								自动移动.Enabled = true;
								Rxjh_X = Rxjh_cs_X;
								Rxjh_Y = Rxjh_cs_Y;
								Rxjh_Z = Rxjh_cs_Z;
								发送移动数据(Rxjh_cs_X, Rxjh_cs_Y, 35, 1);
							}
							else
							{
								int 攻击类型2 = 28;
								int num12 = random.Next(0, 12);
								if (num12 > 9)
								{
									攻击类型2 = 29;
									num2 = (int)((double)num2 * 1.1);
								}
								double num13 = value.人物灵兽.灵兽_防御力 * 2;
								num2 = (((double)num2 <= num13) ? 1 : (num2 - (int)num13));
								if (查找范围玩家(30, value))
								{
									发送攻击数据(num2, 攻击类型2, value.人物灵兽全服ID);
									value.人物灵兽.FLD_HP -= num2;
									if (value.人物灵兽.FLD_HP <= 0)
									{
										value.更新灵兽HP_MP_SP();
										自动攻击.Enabled = false;
										自动移动.Enabled = true;
										Rxjh_X = Rxjh_cs_X;
										Rxjh_Y = Rxjh_cs_Y;
										Rxjh_Z = Rxjh_cs_Z;
										发送移动数据(Rxjh_cs_X, Rxjh_cs_Y, 35, 1);
										value.人物灵兽.FLD_HP = 0;
										value.人物灵兽.FLD_死亡 = 1;
										value.人物灵兽.保存数据();
										value.解除召唤(value, value);
										value.人物灵兽.Dispose();
										value.人物灵兽 = null;
										value.装备栏已穿装备[14].锁定 = false;
									}
									else
									{
										value.更新灵兽HP_MP_SP();
									}
								}
								else if (查找原始范围())
								{
									自动攻击.Enabled = false;
									自动移动.Enabled = true;
									Rxjh_X = Rxjh_cs_X;
									Rxjh_Y = Rxjh_cs_Y;
									Rxjh_Z = Rxjh_cs_Z;
									发送移动数据(Rxjh_cs_X, Rxjh_cs_Y, 35, 1);
								}
								else if (查找范围玩家(80, value))
								{
									发送移动数据(value.人物灵兽.人物坐标_X, value.人物灵兽.人物坐标_Y, 10, 2);
								}
								else
								{
									自动攻击.Enabled = false;
									自动移动.Enabled = true;
									Rxjh_X = Rxjh_cs_X;
									Rxjh_Y = Rxjh_cs_Y;
									Rxjh_Z = Rxjh_cs_Z;
									发送移动数据(Rxjh_cs_X, Rxjh_cs_Y, 35, 1);
								}
							}
						}
						else
						{
							自动攻击.Enabled = false;
							自动移动.Enabled = true;
							Rxjh_X = Rxjh_cs_X;
							Rxjh_Y = Rxjh_cs_Y;
							Rxjh_Z = Rxjh_cs_Z;
							发送移动数据(Rxjh_cs_X, Rxjh_cs_Y, 35, 1);
						}
					}
				}
			}
			catch (Exception ex2)
			{
				自动攻击.Enabled = false;
				自动移动.Enabled = true;
				Rxjh_X = Rxjh_cs_X;
				Rxjh_Y = Rxjh_cs_Y;
				Rxjh_Z = Rxjh_cs_Z;
				发送移动数据(Rxjh_cs_X, Rxjh_cs_Y, 35, 1);
				Form1.WriteLine(1, "自动攻击事件 出错：" + ex2?.ToString());
			}
		}

		public List<NpcClass> 群攻查找范围Npc2(int 数量)
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(1, "NpcClass_群攻查找范围Npc2");
			}
			try
			{
				List<NpcClass> list = new List<NpcClass>();
				int num = 0;
				foreach (NpcClass value in MapClass.GetnpcTemplate(Rxjh_Map).Values)
				{
					if (!value.NPC死亡 && value.IsNpc == 0 && 查找范围Npc(25, value) && value._FLD_INDEX != _FLD_INDEX)
					{
						list.Add(value);
						if (num >= 数量)
						{
							break;
						}
						num++;
					}
				}
				return list;
			}
			catch (Exception ex)
			{
				Form1.WriteLine(1, "群攻查找范围Npc 出错：" + ex?.ToString());
				return null;
			}
		}

		public void 群攻查找范围Npc()
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(1, "NpcClass_群攻查找范围Npc");
			}
			try
			{
				NpcList.Clear();
				int num = 0;
				foreach (NpcClass value in MapClass.GetnpcTemplate(Rxjh_Map).Values)
				{
					if (!value.NPC死亡 && value.IsNpc == 0 && 查找范围Npc(25, value))
					{
						NpcList.Add(value.FLD_INDEX, value);
						if (num > 4)
						{
							break;
						}
						num++;
					}
				}
			}
			catch (Exception ex)
			{
				Form1.WriteLine(1, "群攻查找范围Npc 出错：" + ex?.ToString());
			}
		}

		public static void 更新NPC数据(Dictionary<int, NpcClass> NpcList, Players Playe)
		{
			if (NpcList != null && NpcList.Count > 0)
			{
				using (发包类 发包类 = new 发包类())
				{
					发包类.Write4(NpcList.Count);
					foreach (NpcClass value in NpcList.Values)
					{
						发包类.Write2(value.FLD_INDEX);
						发包类.Write2(value.FLD_INDEX);
						发包类.Write2(value.FLD_PID);
						发包类.Write4(1);
						发包类.Write4(value.Rxjh_HP);
						发包类.Write4(value.Max_Rxjh_HP);
						发包类.Write(value.Rxjh_X);
						发包类.Write(value.Rxjh_Z);
						发包类.Write(value.Rxjh_Y);
						发包类.Write4(1082130432);
						发包类.Write(value.FLD_FACE1);
						发包类.Write(value.FLD_FACE2);
						发包类.Write(value.Rxjh_X);
						发包类.Write(value.Rxjh_Z);
						发包类.Write(value.Rxjh_Y);
						发包类.Write4(0);
						发包类.Write4(0);
						发包类.Write4(0);
					}
					if (Playe.Client != null)
					{
						Playe.Client.SendPak(发包类, 26368, Playe.人物全服ID);
					}
				}
			}
		}

		public static void 更新NPC删除数据(Dictionary<int, NpcClass> NpcList, Players Playe)
		{
			if (NpcList != null && NpcList.Count > 0)
			{
				using (发包类 发包类 = new 发包类())
				{
					foreach (NpcClass value in NpcList.Values)
					{
						发包类.Write4(1);
						发包类.Write2(value.FLD_INDEX);
						发包类.Write2(value.FLD_INDEX);
						发包类.Write2(value.FLD_PID);
						发包类.Write4(1);
						发包类.Write4(value.Rxjh_HP);
						发包类.Write4(value.Max_Rxjh_HP);
						发包类.Write(value.Rxjh_X);
						发包类.Write(value.Rxjh_Z);
						发包类.Write(value.Rxjh_Y);
						发包类.Write4(1082130432);
						发包类.Write(value.FLD_FACE1);
						发包类.Write(value.FLD_FACE2);
						发包类.Write(value.Rxjh_X);
						发包类.Write(value.Rxjh_Z);
						发包类.Write(value.Rxjh_Y);
						发包类.Write4(0);
						发包类.Write4(0);
						发包类.Write4(0);
					}
					if (Playe.Client != null)
					{
						Playe.Client.SendPak(发包类, 26624, Playe.人物全服ID);
					}
				}
			}
		}

		public void 更新NPC复活数据()
		{
			try
			{
				NPC死亡 = false;
				if (自动复活 != null)
				{
					自动复活.Enabled = false;
					自动复活.Close();
					自动复活.Dispose();
					自动复活 = null;
				}
				Rxjh_HP = Max_Rxjh_HP;
				if (_FLD_PID == 15349 || _FLD_PID == 15350)
				{
					Rxjh_X = Rxjh_cs_X;
					Rxjh_Y = Rxjh_cs_Y;
				}
				else if (_FLD_PID == 15121 || _FLD_PID == 15122)
				{
					Rxjh_X = Rxjh_cs_X;
					Rxjh_Y = Rxjh_cs_Y;
				}
				else
				{
					Random random = new Random();
					int num = random.Next(0, 2);
					double num2 = random.NextDouble() * 50.0;
					double num3 = random.NextDouble() * 50.0;
					if (num == 0)
					{
						Rxjh_X = Rxjh_cs_X + (float)num2;
						Rxjh_Y = Rxjh_cs_Y + (float)num3;
					}
					else
					{
						Rxjh_X = Rxjh_cs_X - (float)num2;
						Rxjh_Y = Rxjh_cs_Y - (float)num3;
					}
				}
				Rxjh_Z = Rxjh_cs_Z;
				using (发包类 发包类 = new 发包类())
				{
					发包类.Write4(1);
					发包类.Write2(FLD_INDEX);
					发包类.Write2(FLD_INDEX);
					发包类.Write2(FLD_PID);
					发包类.Write4(1);
					发包类.Write4(Rxjh_HP);
					发包类.Write4(Max_Rxjh_HP);
					发包类.Write(Rxjh_X);
					发包类.Write(Rxjh_Z);
					发包类.Write(Rxjh_Y);
					发包类.Write4(1082130432);
					发包类.Write(FLD_FACE1);
					发包类.Write(FLD_FACE2);
					发包类.Write(Rxjh_X);
					发包类.Write(Rxjh_Z);
					发包类.Write(Rxjh_Y);
					发包类.Write4(0);
					发送当前范围广播数据(发包类, 31488, FLD_INDEX);
				}
			}
			catch (Exception ex)
			{
				Form1.WriteLine(1, "更新NPC复活数据 出错" + FLD_PID.ToString() + "|" + Name + " " + ex.Message);
			}
		}

		public void 更新死亡数据()
		{
			try
			{
				if (!NPC死亡)
				{
					NPC死亡 = true;
				}
				else if (一次性怪)
				{
					Play_null();
					广播NPC死亡数据();
					Dispose();
				}
				else
				{
					自动攻击.Enabled = false;
					自动移动.Enabled = false;
					if (自动复活 != null)
					{
						自动复活.Interval = FLD_NEWTIME * 1000;
						自动复活.Enabled = true;
					}
					else
					{
						自动复活 = new System.Timers.Timer(FLD_NEWTIME * 1000);
						自动复活.Elapsed += 自动复活事件;
						自动复活.Enabled = true;
					}
					Play_null();
					广播NPC死亡数据();
				}
			}
			catch (Exception ex)
			{
				广播NPC死亡数据();
				Form1.WriteLine(1, "更新死亡数据 出错" + FLD_PID.ToString() + "|" + Name + " " + ex?.ToString());
			}
		}

		private void 广播NPC死亡数据()
		{
			using (发包类 pak = new 发包类())
			{
				发送当前范围广播数据(pak, 34816, FLD_INDEX);
			}
		}

		public void 发送移动数据(float X, float Y, int sl, int 移动方式)
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(1, "NpcClass_发送移动数据");
			}
			try
			{
				using (发包类 发包类 = new 发包类())
				{
					Random random = new Random();
					int num = random.Next(0, 2);
					double num2 = random.NextDouble() * (double)sl;
					double num3 = random.NextDouble() * (double)sl;
					if (num == 0)
					{
						Rxjh_X = X + (float)num2;
						Rxjh_Y = Y + (float)num3;
					}
					else
					{
						Rxjh_X = X - (float)num2;
						Rxjh_Y = Y - (float)num3;
					}
					发包类.Write(Rxjh_X);
					发包类.Write(Rxjh_Y);
					发包类.Write(Rxjh_Z);
					发包类.Write4(-1);
					发包类.Write4(移动方式);
					发包类.Write((float)num2);
					发包类.Write4(Rxjh_HP);
					发送当前范围广播数据(发包类, 29696, FLD_INDEX);
				}
			}
			catch (Exception ex)
			{
				Form1.WriteLine(1, "发送移动数据 出错" + FLD_PID.ToString() + "|" + Name + " " + ex.Message);
			}
		}

		public void 发送攻击数据(int 攻击力, int 攻击类型, int 人物全服ID)
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(1, "NpcClass_发送攻击数据");
			}
			try
			{
				using (发包类 发包类 = new 发包类())
				{
					发包类.Write2(人物全服ID);
					发包类.Write2(0);
					发包类.Write4(攻击力);
					发包类.Write4(0);
					发包类.Write4(0);
					发包类.Write4(0);
					发包类.Write4(攻击类型);
					发包类.Write(Rxjh_X);
					发包类.Write(15f);
					发包类.Write(Rxjh_Y);
					发包类.Write(0);
					发包类.Write(1);
					发包类.Write2(0);
					发包类.Write4(0);
					发送当前范围广播数据(发包类, 3072, FLD_INDEX);
				}
			}
			catch (Exception ex)
			{
				Form1.WriteLine(1, "发送攻击数据 出错" + FLD_PID.ToString() + "|" + Name + " " + ex?.ToString());
			}
		}

		public void 发送当前范围广播数据(发包类 pak, int id, int wordid)
		{
			try
			{
				if (PlayList != null)
				{
					foreach (Players value in PlayList.Values)
					{
						if (value.Client != null && value.Client.Running)
						{
							value.Client.SendPak(pak, id, wordid);
						}
					}
				}
			}
			catch (Exception ex)
			{
				Form1.WriteLine(1, "NPC广播数据 出错3：" + ex?.ToString());
			}
		}

		public void 发送死亡数据(int UserWorldId)
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(1, "NpcClass_发送死亡数据");
			}
			if (World.怪物死亡触发器 == 1)
			{
				try
				{
					if (IsNpc != 1)
					{
						if (!NPC死亡)
						{
							NPC死亡 = true;
							try
							{
								获得分配经验();
								Players value;
								if (FLD_BOSS == 1)
								{
									if (World.allConnectedChars.TryGetValue(BossPlayerWid, out value))
									{
										int num = value.Player_Level - Level;
										int num2 = Level - value.Player_Level;
										if (查找范围玩家(700, value) && num < World.获得物品等级差下线 && num2 < World.获得物品等级差上线)
										{
											暴物品(value);
										}
										else
										{
											暴物品(null);
										}
									}
									else
									{
										暴物品(null);
									}
								}
								else if (World.allConnectedChars.TryGetValue(UserPlayerWid, out value))
								{
									暴物品(value);
								}
								else
								{
									暴物品(null);
								}
							}
							catch (Exception)
							{
							}
						}
						if (一次性怪)
						{
							Play_null();
							广播NPC死亡数据();
							Dispose();
						}
						else
						{
							自动攻击.Enabled = false;
							自动移动.Enabled = true;
							if (World.势力战进程 == 3 && (_FLD_PID == 15121 || _FLD_PID == 15122))
							{
								if (_FLD_PID == 15122)
								{
									World.势力战正分数 += 200;
								}
								else
								{
									World.势力战邪分数 += 200;
								}
							}
							if (自动复活 != null)
							{
								自动复活.Interval = FLD_NEWTIME * 1000;
								自动复活.Enabled = true;
							}
							else
							{
								自动复活 = new System.Timers.Timer(FLD_NEWTIME * 1000);
								自动复活.Elapsed += 自动复活事件;
								自动复活.Enabled = true;
							}
							Play_null();
							广播NPC死亡数据();
						}
					}
				}
				catch (Exception ex2)
				{
					Form1.WriteLine(1, "发送死亡数据 出错" + FLD_PID.ToString() + "|" + Name + " " + ex2.Message);
				}
			}
			try
			{
				if (World.allConnectedChars.TryGetValue(UserWorldId, out Players value2) && value2.秘境状态 != 0 && value2.组队id != 0)
				{
					int 人物坐标_地图 = value2.人物坐标_地图;
					string username = "";
					int num3 = 0;
					int num4 = 0;
					组队Class value3 = null;
					if (人物坐标_地图 >= 23800 && 人物坐标_地图 <= 24000)
					{
						if (World.W组队.TryGetValue(value2.组队id, out value3))
						{
							foreach (Players value4 in value3.组队列表.Values)
							{
								if (查找范围玩家(400, value4) && value4.人物_HP > 0)
								{
									num4++;
									if (value4.本队队长 != "" && value4.本队队长 == value4.UserName)
									{
										username = value4.UserName;
										num3 = 1;
									}
								}
							}
						}
						if (num4 < World.秘境人数 && World.W组队.TryGetValue(value2.组队id, out value3))
						{
							foreach (Players value5 in value3.组队列表.Values)
							{
								value5.移动(500f, 1575f, 15f, 101);
								value5.秘境状态 = 0;
								value5.更新武功和状态();
								value5.系统提示("队友逃跑:秘境内队友不足" + World.秘境人数.ToString() + "人,挑战秘境失败！，", 10, "系统提示");
							}
							World.发送游戏特殊公告("玩家:【" + value2.UserName + "】的队伍少人,秘境挑战失败！", 22, "秘境挑战");
						}
						switch (num3)
						{
						case 0:
							if (World.W组队.TryGetValue(value2.组队id, out value3))
							{
								foreach (Players value6 in value3.组队列表.Values)
								{
									value6.移动(500f, 1575f, 15f, 101);
									value6.秘境状态 = 0;
									value6.更新武功和状态();
									value6.系统提示("队长不在秘境范围内,挑战秘境失败！，", 10, "系统提示");
								}
							}
							World.发送游戏特殊公告("玩家:【" + value2.UserName + "】的队伍队长逃跑,秘境挑战失败！", 23, "秘境挑战");
							break;
						case 1:
						{
							Players players = World.检查玩家name(username);
							if (World.W组队.TryGetValue(value2.组队id, out value3))
							{
								foreach (Players value7 in value3.组队列表.Values)
								{
									value7.秘境分数++;
									value7.系统提示("当前队伍秘境分:[" + players.秘境分数.ToString() + "]加油！", 10, "系统提示");
								}
							}
							break;
						}
						}
					}
					else
					{
						if (World.W组队.TryGetValue(value2.组队id, out value3))
						{
							foreach (Players value8 in value3.组队列表.Values)
							{
								value8.移动(500f, 1575f, 15f, 101);
								value8.秘境状态 = 0;
								value8.更新武功和状态();
								value8.系统提示("有队友不在秘境地图内,全队挑战失败！", 10, "系统提示");
							}
						}
						World.发送游戏特殊公告("玩家:【" + value2.UserName + "】的队友逃离秘境,秘境挑战失败！", 21, "秘境挑战");
					}
				}
			}
			catch (Exception ex3)
			{
				Form1.WriteLine(1, "秘境计分出错--" + ex3.Message);
			}
		}

		public void 发送反伤攻击数据(int 攻击力, int 人物ID)
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(1, "NpcClass_发送反伤攻击数据");
			}
			string hex = "AA55130001B73089000E003D0100000B0000000100000055AA";
			byte[] array = Converter.hexStringToByte(hex);
			Buffer.BlockCopy(BitConverter.GetBytes(FLD_INDEX), 0, array, 5, 2);
			Buffer.BlockCopy(BitConverter.GetBytes(人物ID), 0, array, 11, 2);
			Buffer.BlockCopy(BitConverter.GetBytes(攻击力), 0, array, 19, 2);
			广播数据(array, array.Length);
		}

		public byte[] 掉出物品(DropClass drop, Players yxqname)
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(1, "NpcClass_掉出物品");
			}
			byte[] result;
			try
			{
				long dBItmeId = RxjhClass.GetDBItmeId();
				byte[] array = new byte[73];
				byte[] bytes = BitConverter.GetBytes(dBItmeId);
				byte[] array2 = new byte[56];
				if (World.Itme.TryGetValue(drop.FLD_PID, out ItmeClass value))
				{
					if (value.FLD_QUESTITEM != 1)
					{
						try
						{
							if (World.Droplog)
							{
								Form1.WriteLine(4, "掉落[账号:" + yxqname.Userid + "][角色:" + yxqname.UserName + "][地图:" + 坐标Class.getmapname(yxqname.人物坐标_地图) + "][怪物:" + Name + "][物品:" + drop.FLD_NAME + "] 属性1[" + drop.FLD_MAGIC0.ToString() + "]属性2[" + drop.FLD_MAGIC1.ToString() + "]属性3[" + drop.FLD_MAGIC2.ToString() + "]属性4[" + drop.FLD_MAGIC3.ToString() + "]属性5[" + drop.FLD_MAGIC4.ToString() + "]");
							}
							if (yxqname.FLD_Offline == 1 && drop.是否提示 == 1 && FLD_BOSS == 0)
							{
								string text = "恭喜玩家[" + yxqname.UserName + "]获得[" + drop.FLD_NAME + "]正在[" + 坐标Class.getmapname(yxqname.人物坐标_地图) + "]击杀怪物:" + Name;
								if (World.是否开启全服掉落提示 == 1)
								{
									World.conn.发送("掉落全线提示|" + text + "|" + World.服务器ID.ToString() + "线掉落提示");
								}
								if (World.是否开启全服掉落提示 == 0)
								{
									World.系统全局提示("掉落提示", text ?? "", 10);
								}
							}
							Buffer.BlockCopy(BitConverter.GetBytes(drop.FLD_MAGIC0), 0, array2, 0, 4);
							Buffer.BlockCopy(BitConverter.GetBytes(drop.FLD_MAGIC1), 0, array2, 4, 4);
							Buffer.BlockCopy(BitConverter.GetBytes(drop.FLD_MAGIC2), 0, array2, 8, 4);
							Buffer.BlockCopy(BitConverter.GetBytes(drop.FLD_MAGIC3), 0, array2, 12, 4);
							Buffer.BlockCopy(BitConverter.GetBytes(drop.FLD_MAGIC4), 0, array2, 16, 4);
							Buffer.BlockCopy(bytes, 0, array, 0, 4);
							Buffer.BlockCopy(array2, 0, array, 16, 56);
							Buffer.BlockCopy(BitConverter.GetBytes(drop.FLD_PID), 0, array, 8, 4);
							Buffer.BlockCopy(BitConverter.GetBytes(1), 0, array, 12, 4);
						}
						catch (Exception ex)
						{
							Form1.WriteLine(1, "掉出物品1 出错 " + FLD_PID.ToString() + "|" + Name + " " + ex.Message);
							result = null;
							return result;
						}
						地面物品类 地面物品类;
						try
						{
							地面物品类 = new 地面物品类(array, Rxjh_X, Rxjh_Y, Rxjh_Z, Rxjh_Map, yxqname, drop.是否提示, Name, drop.FLD_NAME);
							if (地面物品类 == null)
							{
								Form1.WriteLine(1, "掉出物品2 出错 " + FLD_PID.ToString() + "|" + Name);
								result = null;
								return result;
							}
							if (!World.ItmeTeM.ContainsKey(dBItmeId))
							{
								World.ItmeTeM.Add(dBItmeId, 地面物品类);
							}
						}
						catch (Exception ex2)
						{
							Form1.WriteLine(1, "掉出物品3 出错 " + FLD_PID.ToString() + "|" + Name + " " + ex2.Message);
							result = null;
							return result;
						}
						try
						{
							if (World.ItmeTeM.ContainsKey(dBItmeId))
							{
								地面物品类.获取范围玩家发送地面增加物品数据包();
							}
							result = array;
							return result;
						}
						catch (Exception ex3)
						{
							Form1.WriteLine(1, "掉出物品4 出错 " + FLD_PID.ToString() + "|" + Name + " " + ex3.Message);
							result = null;
							return result;
						}
					}
					if (yxqname != null)
					{
						if (yxqname.组队id != 0)
						{
							if (World.W组队.TryGetValue(yxqname.组队id, out 组队Class value2))
							{
								foreach (Players value3 in value2.组队列表.Values)
								{
									if (查找范围玩家(700, value3) && value3.检查任务是否匹配(drop.FLD_PID))
									{
										value3.设置任务物品(drop.FLD_PID, 1);
									}
								}
							}
						}
						else if (yxqname.检查任务是否匹配(drop.FLD_PID))
						{
							yxqname.设置任务物品(drop.FLD_PID, 1);
						}
					}
					return null;
				}
				result = null;
			}
			catch (Exception ex4)
			{
				Form1.WriteLine(1, "掉出物品5 出错 " + FLD_PID.ToString() + "|" + Name + " " + ex4.Message);
				result = null;
			}
			finally
			{
				drop.FLD_MAGIC0 = drop.FLD_MAGICNew0;
				drop.FLD_MAGIC1 = drop.FLD_MAGICNew1;
				drop.FLD_MAGIC2 = drop.FLD_MAGICNew2;
				drop.FLD_MAGIC3 = drop.FLD_MAGICNew3;
				drop.FLD_MAGIC4 = drop.FLD_MAGICNew4;
			}
			return result;
		}

		public void 暴物品(Players yxqname)
		{
			try
			{
				if (yxqname == null || World.死亡复活锁定时间 <= 0)
				{
					goto IL_004a;
				}
				int num = (int)DateTime.Now.Subtract(yxqname.复活时间).TotalSeconds;
				if (num > World.死亡复活锁定时间)
				{
					goto IL_004a;
				}
				goto end_IL_0001;
				IL_004a:
				using (new Lock(AsyncLock, "死亡掉落"))
				{
					if (yxqname != null)
					{
						DropClass rwDrop = DropClass.GetRwDrop(yxqname, FLD_PID);
						if (rwDrop != null && World.Itme.TryGetValue(rwDrop.FLD_PID, out ItmeClass value) && value.FLD_QUESTITEM == 1 && yxqname != null)
						{
							if (yxqname.组队id != 0)
							{
								if (World.W组队.TryGetValue(yxqname.组队id, out 组队Class value2))
								{
									foreach (Players value3 in value2.组队列表.Values)
									{
										if (查找范围玩家(700, value3) && value3.检查任务是否匹配(rwDrop.FLD_PID))
										{
											value3.设置任务物品(rwDrop.FLD_PID, 1);
										}
									}
								}
							}
							else if (yxqname.检查任务是否匹配(rwDrop.FLD_PID))
							{
								yxqname.设置任务物品(rwDrop.FLD_PID, 1);
							}
						}
						if (FLD_BOSS == 0)
						{
							if (Level - yxqname.Player_Level <= World.获得物品等级差上线 && yxqname.Player_Level - Level <= World.获得物品等级差下线)
							{
								暴物品2(yxqname);
							}
						}
						else if (FLD_BOSS == 1 && World.BOSS不受越级检测开关 == 1)
						{
							Boss暴物品(yxqname);
						}
						else if (FLD_BOSS == 3 && World.BOSS不受越级检测开关 == 1)
						{
							Boss暴物品(yxqname);
						}
						else if (FLD_BOSS == 4 && World.BOSS不受越级检测开关 == 1)
						{
							Boss暴物品(yxqname);
						}
						else if (FLD_BOSS == 5 && World.BOSS不受越级检测开关 == 1)
						{
							Boss暴物品(yxqname);
						}
						else if (FLD_BOSS == 6 && World.BOSS不受越级检测开关 == 1)
						{
							Boss暴物品(yxqname);
						}
						else if (FLD_BOSS == 7 && World.BOSS不受越级检测开关 == 1)
						{
							Boss暴物品(yxqname);
						}
						else if (FLD_BOSS == 8 && World.BOSS不受越级检测开关 == 1)
						{
							Boss暴物品(yxqname);
						}
						else if (FLD_BOSS == 9 && World.BOSS不受越级检测开关 == 1)
						{
							Boss暴物品(yxqname);
						}
						else if (FLD_BOSS == 10 && World.BOSS不受越级检测开关 == 1)
						{
							Boss暴物品(yxqname);
						}
						else if (FLD_BOSS == 2 && Level - yxqname.Player_Level <= World.获得物品等级差上线 && yxqname.Player_Level - Level <= World.获得物品等级差下线)
						{
							GS暴物品(1, 1, yxqname);
						}
					}
				}
				end_IL_0001:;
			}
			catch (Exception ex)
			{
				Form1.WriteLine(1, "暴物品 错误" + ex?.ToString());
			}
		}

		public void GS暴物品(int sl, int maxsl, Players yxqname)
		{
			try
			{
				if (Rxjh_Exp > 0 && yxqname != null)
				{
					int num = Randomd.Next(1, 10000);
					if (num <= World.暴率)
					{
						List<DropClass> gSDrop = DropClass.GetGSDrop(Level, sl, maxsl, FLD_PID);
						foreach (DropClass item in gSDrop)
						{
							if (item != null)
							{
								switch (item.FLD_PID)
								{
								case 800000011:
								{
									int num15 = new Random().Next(0, 101);
									int fLD_MAGIC4;
									if (num15 != 100)
									{
										fLD_MAGIC4 = ((num15 > 97) ? 100014 : ((num15 > 94) ? 100013 : ((num15 > 91) ? 100012 : ((num15 > 87) ? 100011 : ((num15 <= 82) ? new Random().Next(100005, 100010) : 100010)))));
									}
									else
									{
										fLD_MAGIC4 = 100015;
										new Random().Next(20, 27);
									}
									item.FLD_PID = 800000001;
									item.FLD_MAGIC0 = fLD_MAGIC4;
									break;
								}
								case 800000012:
								{
									int num13 = new Random().Next(0, 101);
									int fLD_MAGIC3;
									if (num13 <= 99)
									{
										fLD_MAGIC3 = ((num13 > 95) ? 200007 : ((num13 > 88) ? 200006 : ((num13 <= 80) ? new Random().Next(200001, 200005) : 200005)));
									}
									else
									{
										fLD_MAGIC3 = 200008;
										new Random().Next(20, 27);
										item.是否提示 = 1;
									}
									item.FLD_PID = 800000002;
									item.FLD_MAGIC0 = fLD_MAGIC3;
									break;
								}
								case 800000013:
									if (item.FLD_MAGIC0 == 0)
									{
										int num7 = Randomd.Next(8010, 8060);
										item.FLD_MAGIC0 = num7 * 100 + 1;
									}
									break;
								case 800000025:
								{
									int num10 = new Random().Next(0, 201);
									int fLD_MAGIC2;
									if (num10 <= 198)
									{
										fLD_MAGIC2 = ((num10 > 195) ? 1000019 : ((num10 > 190) ? 1000018 : ((num10 > 182) ? 1000017 : ((num10 > 175) ? 1000016 : ((num10 <= 160) ? new Random().Next(1000005, 1000018) : 1000015)))));
									}
									else
									{
										new Random().Next(20, 27);
										fLD_MAGIC2 = 1000020;
									}
									item.FLD_PID = 800000001;
									item.FLD_MAGIC0 = fLD_MAGIC2;
									break;
								}
								case 800000026:
								{
									int num4 = new Random().Next(0, 201);
									int fLD_MAGIC;
									if (num4 != 200)
									{
										fLD_MAGIC = ((num4 > 197) ? 700024 : ((num4 > 193) ? 700023 : ((num4 > 185) ? 700022 : ((num4 > 173) ? 700021 : ((num4 <= 155) ? new Random().Next(700010, 700020) : 700020)))));
									}
									else
									{
										new Random().Next(20, 27);
										item.是否提示 = 1;
										fLD_MAGIC = 700025;
									}
									item.FLD_PID = 800000001;
									item.FLD_MAGIC0 = fLD_MAGIC;
									break;
								}
								case 800000028:
									if (item.FLD_MAGIC0 == 0)
									{
										int num14 = Randomd.Next(1, 7);
										string str = "200";
										string str2 = "000";
										string s = str + num14.ToString() + str2;
										item.FLD_MAGIC0 = int.Parse(s);
									}
									break;
								case 800000034:
								{
									Random random4 = new Random();
									int num11 = random4.Next(0, 7);
									switch (num11)
									{
									case 0:
									case 1:
										num11 = 1;
										break;
									case 2:
									case 6:
										num11 = 3;
										break;
									case 3:
										num11 = 5;
										break;
									case 4:
										num11 = 7;
										break;
									case 5:
										num11 = 10;
										break;
									}
									int num12 = random4.Next(10, 21);
									item.FLD_MAGIC0 = num11 * 100000 + num12;
									item.FLD_PID = 800000030;
									break;
								}
								case 800000035:
								{
									Random random3 = new Random();
									int num8 = random3.Next(0, 7);
									switch (num8)
									{
									case 0:
									case 1:
										num8 = 1;
										break;
									case 2:
									case 6:
										num8 = 3;
										break;
									case 3:
										num8 = 5;
										break;
									case 4:
										num8 = 7;
										break;
									case 5:
										num8 = 10;
										break;
									}
									int num9 = random3.Next(15, 26);
									item.FLD_MAGIC0 = num8 * 100000 + num9;
									item.FLD_PID = 800000031;
									break;
								}
								case 800000036:
								{
									Random random2 = new Random();
									int num5 = random2.Next(0, 7);
									switch (num5)
									{
									case 0:
									case 1:
										num5 = 2;
										break;
									case 2:
									case 6:
										num5 = 3;
										break;
									case 3:
										num5 = 4;
										break;
									case 4:
										num5 = 6;
										break;
									case 5:
										num5 = 11;
										break;
									}
									int num6 = random2.Next(8, 11);
									item.FLD_MAGIC0 = num5 * 100000 + num6;
									item.FLD_PID = 800000032;
									break;
								}
								case 800000037:
								{
									Random random = new Random();
									int num2 = random.Next(0, 7);
									switch (num2)
									{
									case 0:
									case 1:
										num2 = 2;
										break;
									case 2:
									case 6:
										num2 = 3;
										break;
									case 3:
										num2 = 4;
										break;
									case 4:
										num2 = 6;
										break;
									case 5:
										num2 = 11;
										break;
									}
									int num3 = random.Next(10, 16);
									item.FLD_MAGIC0 = num2 * 100000 + num3;
									item.FLD_PID = 800000033;
									break;
								}
								}
								掉出物品(item, yxqname);
							}
						}
					}
				}
			}
			catch (Exception)
			{
			}
		}

		public void BossPlayerDrop()
		{
			try
			{
				DropClass dropClass = BOSS地图.获得BOSS持有物品(Rxjh_Map, FLD_PID);
				if (dropClass != null)
				{
					new List<Players>();
					int num = Max_Rxjh_HP / PlayGjList.Count / 2;
					foreach (PlayGjClass playGj in PlayGjList)
					{
						if (playGj.Hitsl >= num && World.allConnectedChars.TryGetValue(playGj.PlayID, out Players value) && 查找范围玩家(700, value))
						{
							掉出物品(dropClass, value);
						}
					}
				}
			}
			catch (Exception ex)
			{
				Form1.WriteLine(1, "BossPlayerDrop error " + ex?.ToString());
			}
		}

		public void Boss暴物品(Players yxqname)
		{
			try
			{
				if (Rxjh_Exp > 0)
				{
					if (BOSS地图.cheekBossMap(Rxjh_Map))
					{
						BossPlayerDrop();
					}
					List<DropClass> bossDrop = DropClass.GetBossDrop(yxqname.Player_Level, FLD_PID);
					foreach (DropClass item in bossDrop)
					{
						if (item != null)
						{
							switch (item.FLD_PID)
							{
							case 800000011:
							{
								int num14 = new Random().Next(0, 101);
								int fLD_MAGIC4;
								if (num14 != 100)
								{
									fLD_MAGIC4 = ((num14 > 97) ? 100014 : ((num14 > 94) ? 100013 : ((num14 > 91) ? 100012 : ((num14 > 87) ? 100011 : ((num14 <= 82) ? new Random().Next(100005, 100010) : 100010)))));
								}
								else
								{
									fLD_MAGIC4 = 100015;
									new Random().Next(20, 27);
								}
								item.FLD_PID = 800000001;
								item.FLD_MAGIC0 = fLD_MAGIC4;
								break;
							}
							case 800000012:
							{
								int num12 = new Random().Next(0, 101);
								int fLD_MAGIC3;
								if (num12 <= 99)
								{
									fLD_MAGIC3 = ((num12 > 95) ? 200007 : ((num12 > 88) ? 200006 : ((num12 <= 80) ? new Random().Next(200001, 200005) : 200005)));
								}
								else
								{
									fLD_MAGIC3 = 200008;
									new Random().Next(20, 27);
									item.是否提示 = 1;
								}
								item.FLD_PID = 800000002;
								item.FLD_MAGIC0 = fLD_MAGIC3;
								break;
							}
							case 800000013:
								if (item.FLD_MAGIC0 == 0)
								{
									int num6 = Randomd.Next(8010, 8060);
									item.FLD_MAGIC0 = num6 * 100 + 1;
								}
								break;
							case 800000025:
							{
								int num9 = new Random().Next(0, 201);
								int fLD_MAGIC2;
								if (num9 <= 198)
								{
									fLD_MAGIC2 = ((num9 > 195) ? 1000019 : ((num9 > 190) ? 1000018 : ((num9 > 182) ? 1000017 : ((num9 > 175) ? 1000016 : ((num9 <= 160) ? new Random().Next(1000005, 1000018) : 1000015)))));
								}
								else
								{
									new Random().Next(20, 27);
									fLD_MAGIC2 = 1000020;
								}
								item.FLD_PID = 800000001;
								item.FLD_MAGIC0 = fLD_MAGIC2;
								break;
							}
							case 800000026:
							{
								int num3 = new Random().Next(0, 201);
								int fLD_MAGIC;
								if (num3 != 200)
								{
									fLD_MAGIC = ((num3 > 197) ? 700024 : ((num3 > 193) ? 700023 : ((num3 > 185) ? 700022 : ((num3 > 173) ? 700021 : ((num3 <= 155) ? new Random().Next(700010, 700020) : 700020)))));
								}
								else
								{
									new Random().Next(20, 27);
									item.是否提示 = 1;
									fLD_MAGIC = 700025;
								}
								item.FLD_PID = 800000001;
								item.FLD_MAGIC0 = fLD_MAGIC;
								break;
							}
							case 800000028:
								if (item.FLD_MAGIC0 == 0)
								{
									int num13 = Randomd.Next(1, 7);
									string str = "200";
									string str2 = "000";
									string s = str + num13.ToString() + str2;
									item.FLD_MAGIC0 = int.Parse(s);
								}
								break;
							case 800000034:
							{
								Random random4 = new Random();
								int num10 = random4.Next(0, 7);
								switch (num10)
								{
								case 0:
								case 1:
									num10 = 1;
									break;
								case 2:
								case 6:
									num10 = 3;
									break;
								case 3:
									num10 = 5;
									break;
								case 4:
									num10 = 7;
									break;
								case 5:
									num10 = 10;
									break;
								}
								int num11 = random4.Next(10, 21);
								item.FLD_MAGIC0 = num10 * 100000 + num11;
								item.FLD_PID = 800000030;
								break;
							}
							case 800000035:
							{
								Random random3 = new Random();
								int num7 = random3.Next(0, 7);
								switch (num7)
								{
								case 0:
								case 1:
									num7 = 1;
									break;
								case 2:
								case 6:
									num7 = 3;
									break;
								case 3:
									num7 = 5;
									break;
								case 4:
									num7 = 7;
									break;
								case 5:
									num7 = 10;
									break;
								}
								int num8 = random3.Next(15, 26);
								item.FLD_MAGIC0 = num7 * 100000 + num8;
								item.FLD_PID = 800000031;
								break;
							}
							case 800000036:
							{
								Random random2 = new Random();
								int num4 = random2.Next(0, 7);
								switch (num4)
								{
								case 0:
								case 1:
									num4 = 2;
									break;
								case 2:
								case 6:
									num4 = 3;
									break;
								case 3:
									num4 = 4;
									break;
								case 4:
									num4 = 6;
									break;
								case 5:
									num4 = 11;
									break;
								}
								int num5 = random2.Next(8, 11);
								item.FLD_MAGIC0 = num4 * 100000 + num5;
								item.FLD_PID = 800000032;
								break;
							}
							case 800000037:
							{
								Random random = new Random();
								int num = random.Next(0, 7);
								switch (num)
								{
								case 0:
								case 1:
									num = 2;
									break;
								case 2:
								case 6:
									num = 3;
									break;
								case 3:
									num = 4;
									break;
								case 4:
									num = 6;
									break;
								case 5:
									num = 11;
									break;
								}
								int num2 = random.Next(10, 16);
								item.FLD_MAGIC0 = num * 100000 + num2;
								item.FLD_PID = 800000033;
								break;
							}
							}
							掉出物品(item, yxqname);
						}
					}
				}
			}
			catch (Exception)
			{
			}
		}

		public void 暴物品2(Players yxqname)
		{
			try
			{
				if (Rxjh_Exp > 0 && yxqname.Player_LockState != 0)
				{
					double num = World.暴率;
					if (Rxjh_Map == 1301 || Rxjh_Map == 5001)
					{
						num = (int)((double)World.暴率 * 1.1);
					}
					int num2 = Randomd.Next(1, 8000);
					if (yxqname != null)
					{
						if (yxqname.手动追加爆率 > 0.0)
						{
							num -= (double)(int)(num + yxqname.手动追加爆率);
						}
						if (yxqname.门派追加爆率百分比 > 0.0)
						{
							num += (double)(int)(num * yxqname.门派追加爆率百分比);
						}
						if (yxqname.FLD_群医_追加_爆率百分比 > 0.0)
						{
							num += (double)(int)(num * yxqname.FLD_群医_追加_爆率百分比);
						}
						if (yxqname.积分BUFF追加爆率百分比 > 0.0)
						{
							num += (double)(int)(num * yxqname.积分BUFF追加爆率百分比);
						}
						if (yxqname.爱情度追加爆率百分比 > 0.0)
						{
							num += (double)(int)(num * yxqname.爱情度追加爆率百分比);
						}
						if (yxqname.FLD_宠物_追加_暴率百分比 > 0.0)
						{
							num += (double)(int)(num * yxqname.FLD_宠物_追加_暴率百分比);
						}
						if (yxqname.FLD_武勋_追加_物品掉落概率百分比 > 0.0)
						{
							num += (double)(int)(num * yxqname.FLD_武勋_追加_物品掉落概率百分比);
						}
						if (yxqname.Player_Job == 1)
						{
							num *= World.刀客暴率百分比;
						}
						if (yxqname.FLD_人物_追加_爆率百分比 != 0.0)
						{
							num += num * yxqname.FLD_人物_追加_爆率百分比;
						}
						if (yxqname.检查公有药品())
						{
							num = num * 11.0 / 10.0;
						}
						double num3 = 0.0;
						int num4 = 0;
						int num5 = 0;
						bool flag = false;
						if (yxqname.组队id != 0)
						{
							if (World.W组队.TryGetValue(yxqname.组队id, out 组队Class value))
							{
								int num6 = 0;
								int num7 = 0;
								int num8 = 0;
								int num9 = 0;
								int num10 = 0;
								int num11 = 0;
								int num12 = 0;
								int num13 = 0;
								int num14 = 0;
								int num15 = 0;
								int num16 = 0;
								foreach (Players value2 in value.组队列表.Values)
								{
									if (value2.Player_Job == 1)
									{
										num6++;
									}
									else if (value2.Player_Job == 2)
									{
										num7++;
									}
									else if (value2.Player_Job == 3)
									{
										num8++;
									}
									else if (value2.Player_Job == 4)
									{
										num9++;
									}
									else if (value2.Player_Job == 5)
									{
										num10++;
									}
								}
								if (num6 > World.刀客数量 && World.刀客无爆率 == 1)
								{
									num -= (double)World.暴率;
								}
								if (num7 > World.剑客数量 && World.剑客无爆率 == 1)
								{
									num -= (double)World.暴率;
								}
								if (num8 > World.枪客数量 && World.枪客无爆率 == 1)
								{
									num -= (double)World.暴率;
								}
								if (num9 > World.弓箭手数量 && World.弓箭手无爆率 == 1)
								{
									num -= (double)World.暴率;
								}
								if (num10 > World.医生数量 && World.医生无爆率 == 1)
								{
									num -= (double)World.暴率;
								}
								foreach (Players value3 in value.组队列表.Values)
								{
									if (value3.Player_Job != 1)
									{
										if (value3.Player_Job == 4 || value3.Player_Job == 5)
										{
											num5++;
										}
									}
									else if (value3.Player_Level >= 55)
									{
										num4++;
									}
									if (查找范围玩家(700, value3))
									{
										if (value3.Player_Job == 5 && value3.Player_Job_leve > 3 && value3.医_天佑之气 > num3)
										{
											num3 = value3.医_天佑之气;
										}
										num16++;
										if (value3.Player_Job == 5)
										{
											num12++;
										}
										else if (value3.Player_Job == 4)
										{
											num11++;
										}
										else if (value3.Player_Job == 3)
										{
											num13++;
										}
										else if (value3.Player_Job == 2)
										{
											num14++;
										}
										else if (value3.Player_Job == 1)
										{
											num15++;
										}
									}
								}
								flag = (num5 != 0 && num12 != 0 && num13 != 0 && num14 != 0 && num15 != 0);
							}
						}
						else if (yxqname.Player_Job == 5 && yxqname.Player_Job_leve > 3)
						{
							num3 = yxqname.医_天佑之气;
						}
						else if (yxqname.Player_Job == 4)
						{
							num = num * 9.0 / 10.0;
						}
						num2 -= (int)((double)num2 * num3);
						if (yxqname.Player_Job == 1)
						{
							num2 = num2 * 11 / 10;
						}
						else if (yxqname.Player_Job == 4)
						{
							num2 = ((!yxqname.检查公有药品()) ? (num2 * 13 / 10) : (num2 * 11 / 10));
						}
						if (flag)
						{
							num2 = num2 * 10 / 12;
						}
						if (Level > yxqname.Player_Level)
						{
							num2 = num2 * 12 / 10;
						}
						if (num4 > 2)
						{
							num2 = ((num4 != 8) ? (num2 * (num4 + 4) / (8 - num4)) : 8000);
						}
						if (num5 > 2)
						{
							num2 = ((num5 != 8) ? (num2 * (num5 + 4) / (8 - num5)) : 8000);
						}
					}
					if ((double)num2 <= num)
					{
						DropClass drop = DropClass.GetDrop(yxqname, Level, FLD_PID);
						if (drop != null)
						{
							switch (drop.FLD_PID)
							{
							case 800000011:
							{
								int num30 = new Random().Next(0, 101);
								int fLD_MAGIC4;
								if (num30 != 100)
								{
									fLD_MAGIC4 = ((num30 > 97) ? 100014 : ((num30 > 94) ? 100013 : ((num30 > 91) ? 100012 : ((num30 > 87) ? 100011 : ((num30 <= 82) ? new Random().Next(100005, 100010) : 100010)))));
								}
								else
								{
									fLD_MAGIC4 = 100015;
									new Random().Next(20, 27);
								}
								drop.FLD_PID = 800000001;
								drop.FLD_MAGIC0 = fLD_MAGIC4;
								break;
							}
							case 800000012:
							{
								int num28 = new Random().Next(0, 101);
								int fLD_MAGIC3;
								if (num28 <= 99)
								{
									fLD_MAGIC3 = ((num28 > 95) ? 200007 : ((num28 > 88) ? 200006 : ((num28 <= 80) ? new Random().Next(200001, 200005) : 200005)));
								}
								else
								{
									fLD_MAGIC3 = 200008;
									new Random().Next(20, 27);
									drop.是否提示 = 1;
								}
								drop.FLD_PID = 800000002;
								drop.FLD_MAGIC0 = fLD_MAGIC3;
								break;
							}
							case 800000013:
								if (drop.FLD_MAGIC0 == 0)
								{
									int num22 = Randomd.Next(8010, 8060);
									drop.FLD_MAGIC0 = num22 * 100 + 1;
								}
								break;
							case 800000025:
							{
								int num25 = new Random().Next(0, 201);
								int fLD_MAGIC2;
								if (num25 <= 198)
								{
									fLD_MAGIC2 = ((num25 > 195) ? 1000019 : ((num25 > 190) ? 1000018 : ((num25 > 182) ? 1000017 : ((num25 > 175) ? 1000016 : ((num25 <= 160) ? new Random().Next(1000005, 1000018) : 1000015)))));
								}
								else
								{
									new Random().Next(20, 27);
									fLD_MAGIC2 = 1000020;
								}
								drop.FLD_PID = 800000001;
								drop.FLD_MAGIC0 = fLD_MAGIC2;
								break;
							}
							case 800000026:
							{
								int num19 = new Random().Next(0, 201);
								int fLD_MAGIC;
								if (num19 != 200)
								{
									fLD_MAGIC = ((num19 > 197) ? 700024 : ((num19 > 193) ? 700023 : ((num19 > 185) ? 700022 : ((num19 > 173) ? 700021 : ((num19 <= 155) ? new Random().Next(700010, 700020) : 700020)))));
								}
								else
								{
									new Random().Next(20, 27);
									drop.是否提示 = 1;
									fLD_MAGIC = 700025;
								}
								drop.FLD_PID = 800000001;
								drop.FLD_MAGIC0 = fLD_MAGIC;
								break;
							}
							case 800000028:
								if (drop.FLD_MAGIC0 == 0)
								{
									int num29 = Randomd.Next(1, 7);
									string str = "200";
									string str2 = "000";
									string s = str + num29.ToString() + str2;
									drop.FLD_MAGIC0 = int.Parse(s);
								}
								break;
							case 800000034:
							{
								Random random4 = new Random();
								int num26 = random4.Next(0, 7);
								switch (num26)
								{
								case 0:
								case 1:
									num26 = 1;
									break;
								case 2:
								case 6:
									num26 = 3;
									break;
								case 3:
									num26 = 5;
									break;
								case 4:
									num26 = 7;
									break;
								case 5:
									num26 = 10;
									break;
								}
								int num27 = random4.Next(10, 21);
								drop.FLD_MAGIC0 = num26 * 100000 + num27;
								drop.FLD_PID = 800000030;
								break;
							}
							case 800000035:
							{
								Random random3 = new Random();
								int num23 = random3.Next(0, 7);
								switch (num23)
								{
								case 0:
								case 1:
									num23 = 1;
									break;
								case 2:
								case 6:
									num23 = 3;
									break;
								case 3:
									num23 = 5;
									break;
								case 4:
									num23 = 7;
									break;
								case 5:
									num23 = 10;
									break;
								}
								int num24 = random3.Next(15, 26);
								drop.FLD_MAGIC0 = num23 * 100000 + num24;
								drop.FLD_PID = 800000031;
								break;
							}
							case 800000036:
							{
								Random random2 = new Random();
								int num20 = random2.Next(0, 7);
								switch (num20)
								{
								case 0:
								case 1:
									num20 = 2;
									break;
								case 2:
								case 6:
									num20 = 3;
									break;
								case 3:
									num20 = 4;
									break;
								case 4:
									num20 = 6;
									break;
								case 5:
									num20 = 11;
									break;
								}
								int num21 = random2.Next(8, 11);
								drop.FLD_MAGIC0 = num20 * 100000 + num21;
								drop.FLD_PID = 800000032;
								break;
							}
							case 800000037:
							{
								Random random = new Random();
								int num17 = random.Next(0, 7);
								switch (num17)
								{
								case 0:
								case 1:
									num17 = 2;
									break;
								case 2:
								case 6:
									num17 = 3;
									break;
								case 3:
									num17 = 4;
									break;
								case 4:
									num17 = 6;
									break;
								case 5:
									num17 = 11;
									break;
								}
								int num18 = random.Next(10, 16);
								drop.FLD_MAGIC0 = num17 * 100000 + num18;
								drop.FLD_PID = 800000033;
								break;
							}
							}
							掉出物品(drop, yxqname);
						}
					}
				}
			}
			catch (Exception ex)
			{
				Form1.WriteLine(1, "普通怪暴物品 出错[账号:" + yxqname.Userid + "][角色:" + yxqname.UserName + "][地图:" + 坐标Class.getmapname(yxqname.人物坐标_地图) + "][怪物:" + Name + "][物品ID;" + FLD_PID.ToString() + "][原因;" + ex.Message + "]");
			}
		}

		public bool 查找范围Npc(int far_, NpcClass Npc)
		{
			if (Npc.Rxjh_Map == Rxjh_Map)
			{
				float num = Npc.Rxjh_X - Rxjh_X;
				float num2 = Npc.Rxjh_Y - Rxjh_Y;
				float num3 = (int)Math.Sqrt(num * num + num2 * num2);
				return num3 <= (float)far_;
			}
			return false;
		}

		public bool 查找范围玩家(int far_, Players Playe)
		{
			try
			{
				if (Playe.人物坐标_地图 != Rxjh_Map)
				{
					return false;
				}
				if (Playe.Player死亡)
				{
					return false;
				}
				if (Playe.人物坐标_地图 == 7101)
				{
					far_ = 1000;
				}
				float num = Playe.人物坐标_X - Rxjh_X;
				float num2 = Playe.人物坐标_Y - Rxjh_Y;
				float num3 = (int)Math.Sqrt(num * num + num2 * num2);
				if (num3 <= (float)far_)
				{
					return true;
				}
			}
			catch (Exception ex)
			{
				Form1.WriteLine(1, "查找范围玩家 出错[账号:" + Playe.Userid + "][角色:" + Playe.UserName + "][地图:" + 坐标Class.getmapname(Playe.人物坐标_地图) + "][怪物:" + Name + "][物品ID;" + FLD_PID.ToString() + "][原因;" + ex.Message + "]");
			}
			return false;
		}

		public bool 查找原始范围()
		{
			try
			{
				if ((double)World.怪物移动最大范围 < 1.0)
				{
					return false;
				}
				float num = Rxjh_cs_X - Rxjh_X;
				float num2 = Rxjh_cs_Y - Rxjh_Y;
				float num3 = (int)Math.Sqrt(num * num + num2 * num2);
				if (num3 > World.怪物移动最大范围)
				{
					return true;
				}
			}
			catch (Exception ex)
			{
				Form1.WriteLine(1, "查找原始范围 出错[原因;" + ex.Message + "]");
			}
			return false;
		}

		public bool 查找范围玩家(int far_, 灵兽类 Playe)
		{
			if (Playe.人物坐标_MAP == Rxjh_Map)
			{
				float num = Playe.人物坐标_X - Rxjh_X;
				float num2 = Playe.人物坐标_Y - Rxjh_Y;
				float num3 = (int)Math.Sqrt(num * num + num2 * num2);
				return num3 <= (float)far_;
			}
			return false;
		}

		public bool 获取范围玩家()
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(1, "NpcClass_获取范围玩家");
			}
			try
			{
				foreach (Players value in World.allConnectedChars.Values)
				{
					if (Level >= value.Player_Level - 20 && value.人物_HP > 0 && 查找范围玩家(90, value))
					{
						Play_Add(value);
						return true;
					}
				}
			}
			catch (Exception)
			{
				return false;
			}
			return false;
		}

		public void 广播数据(byte[] data, int length)
		{
			if (World.jlMsg == 1)
			{
				Form1.WriteLine(1, "NpcClass_广播数据2");
			}
			try
			{
				foreach (Players value in PlayList.Values)
				{
					if (value.Client != null && value.Client.Running)
					{
						value.Client.Send(data, length);
					}
				}
			}
			catch (Exception ex)
			{
				Form1.WriteLine(1, "NPC广播数据2 出错2：" + ex?.ToString());
			}
		}
	}
}
